package com.ruoyi.project.propertySystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.propertySystem.domain.InspectItemRecord;
import com.ruoyi.project.propertySystem.service.IInspectItemRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 巡检项记录Controller
 * 
 * @author wangshuo
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/propertySystem/inspectItemRecord")
public class InspectItemRecordController extends BaseController
{
    @Autowired
    private IInspectItemRecordService inspectItemRecordService;

    /**
     * 查询巡检项记录列表
     */
    @PreAuthorize("@ss.hasPermi('propertySystem:inspectItemRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectItemRecord inspectItemRecord)
    {
        startPage();
        List<InspectItemRecord> list = inspectItemRecordService.selectInspectItemRecordList(inspectItemRecord);
        return getDataTable(list);
    }

    /**
     * 导出巡检项记录列表
     */
    @PreAuthorize("@ss.hasPermi('propertySystem:inspectItemRecord:export')")
    @Log(title = "巡检项记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(InspectItemRecord inspectItemRecord)
    {
        List<InspectItemRecord> list = inspectItemRecordService.selectInspectItemRecordList(inspectItemRecord);
        ExcelUtil<InspectItemRecord> util = new ExcelUtil<InspectItemRecord>(InspectItemRecord.class);
        return util.exportExcel(list, "inspectItemRecord");
    }

    /**
     * 获取巡检项记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('propertySystem:inspectItemRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(inspectItemRecordService.selectInspectItemRecordById(id));
    }

    /**
     * 新增巡检项记录
     */
    @PreAuthorize("@ss.hasPermi('propertySystem:inspectItemRecord:add')")
    @Log(title = "巡检项记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectItemRecord inspectItemRecord)
    {
        return toAjax(inspectItemRecordService.insertInspectItemRecord(inspectItemRecord));
    }

    /**
     * 修改巡检项记录
     */
    @PreAuthorize("@ss.hasPermi('propertySystem:inspectItemRecord:edit')")
    @Log(title = "巡检项记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectItemRecord inspectItemRecord)
    {
        return toAjax(inspectItemRecordService.updateInspectItemRecord(inspectItemRecord));
    }

    /**
     * 删除巡检项记录
     */
    @PreAuthorize("@ss.hasPermi('propertySystem:inspectItemRecord:remove')")
    @Log(title = "巡检项记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inspectItemRecordService.deleteInspectItemRecordByIds(ids));
    }
}
